<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>随手快递</title>
		<link rel="stylesheet" type="text/css" href="../../AUI/css/aui.css" />
		<link rel="stylesheet" type="text/css" href="../../font-awesome/css/font-awesome.min.css" />
		<link rel="stylesheet" href="../../myCss/LArea.css">
		<style type="text/css">
		.aui-content {
		margin-top: 45px;
		}
		.aui-list-item-label,.aui-list-item-input input[type="text"]{
				font-size: 14px;
			}
		.aui-list{
			width: 100%;
		}
		.aui-list .aui-list-item .addr{
				padding-left: 0;
			}
			textarea{
				font-size: 14px;
			}
		</style>
	</head>
	<body style="overflow-x: hidden">
		<header class="aui-bar aui-bar-nav" id="aui-header">
			<a class="aui-btn aui-pull-left" tapmode onclick="history.back();">
				<span class="aui-iconfont aui-icon-left"></span>
			</a>
			<div class="aui-title">修改地址</div>
			<div class="aui-btn aui-pull-right" id="save"><small>保存</small></div>
		</header>
		<div class="aui-content aui-margin-b-15">
			<ul class="aui-list aui-form-list">
				<li class="aui-list-item aui-border-b">
					<div class="aui-list-item-inner">
						<div class="aui-list-item-label">
							收件人
						</div>
						<div class="aui-list-item-input">
							<input type="text" placeholder="" id="contacts">
						</div>
					</div>
				</li>
				<li class="aui-list-item aui-border-b">
					<div class="aui-list-item-inner">
						<div class="aui-list-item-label">
							联系方式
						</div>
						<div class="aui-list-item-input">
							<input type="text" placeholder="" id="contactsPhone">
						</div>
					</div>
				</li>
				<li class="aui-list-item aui-border-b">
					<div class="aui-list-item-inner">
						<div class="aui-list-item-label">
							所在地区
						</div>
						<div class="aui-list-item-input aui-list-item-arrow">
							<div class="content-block">
								<input id="address" type="text" readonly  placeholder="请选择"/>
								<input id="value2" type="hidden" />
							</div>
						</div>
					</div>
				</li>
				<li class="aui-list-item">
					<ul class="aui-list">
						<li class="aui-list-item addr">
								<div class="aui-list-item-input"><textarea id="address1" placeholder="请填写详细地址，不少于5个字"></textarea>
							</div>
						</li>
					</ul>
				</li>
			</ul>
		</div>
		<script type="text/javascript" src="../../myJs/jquery-1.12.1.min.js" ></script>
		<script src="../../myJs/jquery.cookie.js"></script>
		<script src="../../myJs/LAreaData1.js"></script>
		<script src="../../myJs/LAreaData2.js"></script>
		<script src="../../myJs/LArea.js"></script>
		<script>
			var area2 = new LArea();
			area2.init({
				'trigger': '#address',
				'valueTo': '#value2',
				'keys': {
					id: 'value',
					name: 'text'
				},
				'type': 2,
				'data': [provs_data, citys_data, dists_data]
			});
		</script>
		<script type="text/javascript">

			/* var data = {
				"code":200,
			"msg":{
				"addressId": 12,
				"address": "浙江省杭州市江干区",
				"addressDetails": "浙江工商大学",
				"contacts": "天天",
				"contactsPhone": "17827382716"
			}} */
			var addressId;
			$(function(){
			addressId = sessionStorage.getItem("addressId");
				 $.ajax({
				 type: "post",
				 url: '/randomdelivery/userManageController/addressMessage',
				 data: {
				 addressId:addressId,
				 },
				 datatype: "json",
				 success: function (data) {
				 address(data);
				 }

				 });
				
			})

			function address(data){
				var data=data.msg;
				$("#contacts").val(data.contacts);
				$("#contactsPhone").val(data.contactsPhone);
				$("#address").val(data.address);
				$("#address1").val(data.addressDetails);
			}

			//保存地址
			$("#save").on("click",function(){
				var contacts = $("#contacts").val();
				var contactsPhone = $("#contactsPhone").val();
				var address = $("#address").val();
				var address1 = $("#address1").val();
				//alert(address);
				//alert(address1);
				 $.ajax({
				 type: "post",
				 url: '/randomdelivery/userManageController/updateAddress',
				 data: {
				 "addressId": addressId,
				 "address": address,
				 "addressDetails": address1,
				 "contacts": contacts,
				 "contactsPhone": contactsPhone
				 },
				 datatype: "json",
				 success: function (data) {
				 location.href="address.html";
				 
				 }

				 });
			})
		</script>
	</body>
</html>